package org.xteam.sled.tree;

import java.util.List;

import org.xteam.sled.model.AbsoluteField;
import org.xteam.sled.tree.TreeBuilder.SplitResult;

public class LeafArmHeuristic extends Heuristic {

	public LeafArmHeuristic() {
		super("leafarms");
	}

	@Override
	public int run(TreeBuilder treeBuilder, List<SplitResult> children,
			AbsoluteField f) {
		int count = 0;
		for (SplitResult res : children) {
			if (!treeBuilder.needsSplitting(res.arms))
				count += 1;
		}
		for (SplitResult res : children) {
			if (res.arms.isEmpty()) {
				count += 1;
				break;
			}
		}
		return count;
	}

}
